
/*
 * TelaCadastroFuncionario.java
 *
 * Created on 27/05/2010, 19:54:44
 */

package br.com.pi.SmartFast.view;

import br.com.pi.SmartFast.controler.ControleTelaCadastroFuncionario;

/**
 *
 * @author Jeferson de Andrade
 */
public class TelaCadastroFuncionario extends javax.swing.JFrame {

    ControleTelaCadastroFuncionario controlFunc;

    /** Creates new form TelaCadastroFuncionario */
    public TelaCadastroFuncionario() {
        initComponents();
        controlFunc = new ControleTelaCadastroFuncionario(botaoSair, jBEditar, jBSalvar,
                jCCategoria, jCGenero, jComboCidade, jComboUF, jPasswordSenha1,
                jPasswordSenha2, jScrollPane1, jTEndereco, jTLogin, jTNome,
                jTableFuncionario, jTfone);

//        controlFunc.carregaCategoria();
//        controlFunc.carregaGenero();
//        controlFunc.carregaUF();
//        controlFunc.carregaCidades();
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabelCadFuncPalavra = new javax.swing.JLabel();
        jTNome = new javax.swing.JTextField();
        jCGenero = new javax.swing.JComboBox();
        jLNome = new javax.swing.JLabel();
        jLGenero = new javax.swing.JLabel();
        jLEndereco = new javax.swing.JLabel();
        jTEndereco = new javax.swing.JTextField();
        jLCidade = new javax.swing.JLabel();
        jComboUF = new javax.swing.JComboBox();
        jLUF = new javax.swing.JLabel();
        jTfone = new javax.swing.JTextField();
        jLFone = new javax.swing.JLabel();
        jLCategoria = new javax.swing.JLabel();
        jCCategoria = new javax.swing.JComboBox();
        jTLogin = new javax.swing.JTextField();
        jPasswordSenha1 = new javax.swing.JPasswordField();
        jLlogin = new javax.swing.JLabel();
        jLsenha = new javax.swing.JLabel();
        jLsenha2 = new javax.swing.JLabel();
        jPasswordSenha2 = new javax.swing.JPasswordField();
        jBSalvar = new javax.swing.JButton();
        jBEditar = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableFuncionario = new javax.swing.JTable();
        botaoSair = new javax.swing.JButton();
        jComboCidade = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setUndecorated(true);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jLabelCadFuncPalavra.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelCadFuncPalavra.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/pi/SmartFast/imagens/imgCadastroFuncionariosPalavra.png"))); // NOI18N

        jCGenero.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jCGeneroFocusGained(evt);
            }
        });

        jLNome.setText("Nome");

        jLGenero.setText("Genero");

        jLEndereco.setText("Endereço");

        jLCidade.setText("Cidade");

        jComboUF.setMaximumRowCount(24);
        jComboUF.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jComboUFMouseClicked(evt);
            }
        });
        jComboUF.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboUFItemStateChanged(evt);
            }
        });
        jComboUF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboUFActionPerformed(evt);
            }
        });
        jComboUF.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jComboUFFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                jComboUFFocusLost(evt);
            }
        });

        jLUF.setText("Unidade Federal");

        jLFone.setText("Telefone");

        jLCategoria.setText("Categoria");

        jCCategoria.setMaximumRowCount(20);
        jCCategoria.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jCCategoriaFocusGained(evt);
            }
        });

        jLlogin.setText("Login");

        jLsenha.setText("Senha");

        jLsenha2.setText("Confirma Senha");

        jPasswordSenha2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jPasswordSenha2KeyReleased(evt);
            }
        });

        jBSalvar.setText("Salvar");
        jBSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSalvarActionPerformed(evt);
            }
        });

        jBEditar.setText("Editar");
        jBEditar.setEnabled(false);
        jBEditar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBEditarActionPerformed(evt);
            }
        });

        jTableFuncionario.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Cod. Funcionario", "Nome", "Categoria"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableFuncionario.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableFuncionarioMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTableFuncionario);

        botaoSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/pi/SmartFast/imagens/imgSair.png"))); // NOI18N
        botaoSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoSairActionPerformed(evt);
            }
        });

        jComboCidade.setMaximumRowCount(24);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(132, 132, 132)
                .addComponent(jLabelCadFuncPalavra, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(451, 451, 451))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLNome, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(536, 536, 536)
                        .addComponent(jLGenero, javax.swing.GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE)
                        .addGap(305, 305, 305))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTNome, javax.swing.GroupLayout.DEFAULT_SIZE, 545, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jCGenero, 0, 121, Short.MAX_VALUE)
                        .addGap(219, 219, 219))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jBSalvar, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jBEditar, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
                        .addGap(661, 661, 661))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 563, Short.MAX_VALUE)
                        .addGap(340, 340, 340))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jCCategoria, 0, 275, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLlogin, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGap(215, 215, 215))
                            .addComponent(jTLogin, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE))
                        .addGap(33, 33, 33)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLFone, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGap(159, 159, 159))
                                    .addComponent(jTfone, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE))
                                .addGap(136, 136, 136))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPasswordSenha1, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLsenha, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGap(120, 120, 120)))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLsenha2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGap(93, 93, 93))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGap(56, 56, 56)
                                        .addComponent(botaoSair, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addComponent(jPasswordSenha2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLCategoria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGap(71, 71, 71))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLUF, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGap(40, 40, 40))
                            .addComponent(jComboUF, 0, 118, Short.MAX_VALUE))
                        .addGap(46, 46, 46)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLCidade, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGap(344, 344, 344))
                            .addComponent(jComboCidade, 0, 377, Short.MAX_VALUE))
                        .addGap(362, 362, 362))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTEndereco, javax.swing.GroupLayout.DEFAULT_SIZE, 787, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLEndereco, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGap(742, 742, 742)))
                        .addGap(116, 116, 116)))
                .addGap(297, 297, 297))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabelCadFuncPalavra)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLNome)
                    .addComponent(jLGenero))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jCGenero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLEndereco)
                .addGap(6, 6, 6)
                .addComponent(jTEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLCidade)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLUF)
                        .addGap(6, 6, 6)
                        .addComponent(jComboUF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLFone)
                        .addGap(6, 6, 6)
                        .addComponent(jTfone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLCategoria)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLsenha)
                                .addComponent(jLlogin)))
                        .addGap(6, 6, 6)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCCategoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPasswordSenha1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLsenha2)
                        .addGap(6, 6, 6)
                        .addComponent(jPasswordSenha2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jBSalvar)
                            .addComponent(jBEditar))
                        .addGap(6, 6, 6)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(botaoSair))
                .addContainerGap(159, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botaoSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoSairActionPerformed
        this.dispose();
}//GEN-LAST:event_botaoSairActionPerformed

    private void jCGeneroFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jCGeneroFocusGained
        controlFunc.carregaGenero();
    }//GEN-LAST:event_jCGeneroFocusGained

    private void jCCategoriaFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jCCategoriaFocusGained
       controlFunc.carregaCategoria();
    }//GEN-LAST:event_jCCategoriaFocusGained

    private void jPasswordSenha2KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPasswordSenha2KeyReleased
        controlFunc.verificaSenha();
    }//GEN-LAST:event_jPasswordSenha2KeyReleased

    private void jBSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSalvarActionPerformed
        controlFunc.botaoSalvar();
    }//GEN-LAST:event_jBSalvarActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        controlFunc.setPreencheTabela();
        controlFunc.carregaUF();
        controlFunc.carregaCategoria();
        controlFunc.carregaGenero();
        controlFunc.carregaCidades(jComboUF.getSelectedItem().toString());
        
    }//GEN-LAST:event_formWindowOpened

    private void jTableFuncionarioMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableFuncionarioMouseClicked
        controlFunc.duploCliqueTabelaFuncionario(evt.getClickCount());

    }//GEN-LAST:event_jTableFuncionarioMouseClicked

    private void jBEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBEditarActionPerformed
        controlFunc.botaoEditar();
    }//GEN-LAST:event_jBEditarActionPerformed

    private void jComboUFMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jComboUFMouseClicked

    }//GEN-LAST:event_jComboUFMouseClicked

    private void jComboUFItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboUFItemStateChanged

    }//GEN-LAST:event_jComboUFItemStateChanged

    private void jComboUFFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboUFFocusLost
        controlFunc.carregaCidades(jComboUF.getSelectedItem().toString());
    }//GEN-LAST:event_jComboUFFocusLost

    private void jComboUFFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboUFFocusGained
               
    }//GEN-LAST:event_jComboUFFocusGained

    private void jComboUFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboUFActionPerformed
       jComboCidade.requestFocus();
    }//GEN-LAST:event_jComboUFActionPerformed

    /**
    * @param args the command line arguments
    */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new TelaCadastroFuncionario().setVisible(true);
//            }
//        });
//    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoSair;
    private javax.swing.JButton jBEditar;
    private javax.swing.JButton jBSalvar;
    private javax.swing.JComboBox jCCategoria;
    private javax.swing.JComboBox jCGenero;
    private javax.swing.JComboBox jComboCidade;
    private javax.swing.JComboBox jComboUF;
    private javax.swing.JLabel jLCategoria;
    private javax.swing.JLabel jLCidade;
    private javax.swing.JLabel jLEndereco;
    private javax.swing.JLabel jLFone;
    private javax.swing.JLabel jLGenero;
    private javax.swing.JLabel jLNome;
    private javax.swing.JLabel jLUF;
    private javax.swing.JLabel jLabelCadFuncPalavra;
    private javax.swing.JLabel jLlogin;
    private javax.swing.JLabel jLsenha;
    private javax.swing.JLabel jLsenha2;
    private javax.swing.JPasswordField jPasswordSenha1;
    private javax.swing.JPasswordField jPasswordSenha2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTEndereco;
    private javax.swing.JTextField jTLogin;
    private javax.swing.JTextField jTNome;
    private javax.swing.JTable jTableFuncionario;
    private javax.swing.JTextField jTfone;
    // End of variables declaration//GEN-END:variables

}
